package train48days;


import java.util.*;
public class 电话号码 {
    //是否是数字
    public static boolean isDigit(char s) {
        return (s >= '0' && s <= '9');
    }

    //是否是大写
    public static boolean isUpper(char s) {
        return (s >= 'A' && s <= 'Z');
    }

    public static void main(String[] args) throws Exception {
        Map<Character, Character> map = new HashMap<>();
        String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String num = "22233344455566677778889999";
        char[] alphach = alpha.toCharArray();
        char[] numch = num.toCharArray();
        for (int i = 0; i < alphach.length; i++) {
            map.put(alphach[i], numch[i]);
        }
        Set<String> set = new TreeSet<>();

        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            set.clear();
            int n = sc.nextInt();
            sc.nextLine();
            for (int i = 0; i < n; i++) {
                String s =sc.nextLine();
                char[] linech = s.toCharArray();
                StringBuilder sb = new StringBuilder();
                for(char ch : linech){
                    if(isDigit(ch)){
                        sb.append(ch);
                    }else if(isUpper(ch)){
                        sb.append(map.get(ch));
                    }
                }
                s = sb.substring(0,3) + "-" + sb.substring(3);
                set.add(s);
            }
            for (String s : set) {
                System.out.println(s);
            }
            //处理下一组数据和上一组数据之间有一个空格
            System.out.println();

        }
    }
}